import InstallCommon, os




def InstallWebFiles():
    print "Overwrite /var/www/html index.html and style.css files and extract OpenLayers? Y/N"
    Response = raw_input().lower()
    if not ('y' in Response):
        return 
    FileName = '/var/www/html/style.css'
    File=open(FileName, 'w')
    File.write(www_style_css)
    File.close()
    FileName = '/var/www/html/index.html'
    File=open(FileName, 'w')
    File.write(www_index_html)
    File.close()
    FileName = '/opt/coopgis/OpenLayers-2.13.1.tar.gz'
    DestinationFolder = '/var/www/openlayers'
    os.system('mkdir ' + DestinationFolder)
    os.system('tar -zxvf ' + FileName + ' -C ' + DestinationFolder)
    os.system('cp ' + DestinationFolder + '/OpenLayers-2.13.1/* ' + DestinationFolder + ' -R')
    os.system('rm -R ' + DestinationFolder + '/OpenLayers-2.13.1')
    os.system('sudo ln /usr/lib/cgi-bin/mapserv /usr/lib/cgi-bin/mapserv.cgi')
    os.system('cp /opt/coopgis/mapbackground.png /var/www/html/mapbackground.png')




www_index_html = """<!--
#    Copyright 2014 COOPGIS Consulting
#    This file is part of COOPGIS.
#    COOPGIS is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    COOPGIS is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with COOPGIS.  If not, see <http://www.gnu.org/licenses/>.
-->


<html>
  <head>
    <title>COOP Map Server Links Redirect Page</title>
<meta http-equiv="REFRESH" content="0;url=/coopgis/">
  </head>
  <body>
COOP GIS Redirect Page<br>
<a href="/coopgis/">Click Here for COOP GIS.  Normally you should automatically be redirected.</a>
  </body>
</html>"""


www_style_css = """/*    Copyright 2014 COOPGIS Consulting
#    This file is part of COOPGIS.
#    COOPGIS is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    COOPGIS is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with COOPGIS.  If not, see <http://www.gnu.org/licenses/>.*/


a:link { color: rgb(18, 89, 20); text-decoration:none; }
a:visited { color: rgb(18, 89, 20); text-decoration:none;}
a:hover { color: rgb(200, 20, 20); text-decoration:none;}
a:focus, a:active { color: #C90016; background-color: white; text-decoration:none;}
a:table { empty-cells: show;}

body {
	background-image: url(/images/MainMenuBackground.jpg);
        background-repeat: no-repeat;
        background-size: 100%;
        color: black;
        background-color: white;}


h1 { 
	margin-top: .5em; 
	margin-bottom: .5em;
	margin-left: .5em;
	margin-right: .5em;
        font: 130% Times, serif;
        font-weight: bold;}

#logo {
        margin-left: .5em;}


.MainMenuButton {
        border: 0px solid blue;}


#Warning {
        font: 250% Times, serif;
        font-weight: bold;
	margin: 0;
        color: red;
	position: absolute;
	top: 50px;
	left: 10px;
        text-decoration: blink;
}

#LoginButton {
	margin: 0;
	position: absolute;
	top: 10px;
	left: 350px; 
        font: 230% Times, serif;
        font-weight: bold;}

#LogoutButton {
	margin: 0;
	position: absolute;
	top: 10px;
	left: 475px; 
        font: 230% Times, serif;
        font-weight: bold;}
#PasswordButton {
	margin: 0;
	position: absolute;
	top: 10px;
	left: 625px; 
        font: 230% Times, serif;
        font-weight: bold;}

#ShapeButton {
	margin: 0;
	position: absolute;
	top: 10px;
	left: 800px; 
font: 230% Times, serif;
        font-weight: bold;}
#UpdateButton {
	margin: 0;
	position: absolute;
	top: 60px;
	left: 800px; 
font: 230% Times, serif;
        font-weight: bold;}
#NonGISButton {
	margin: 0;
	position: absolute;
	top: 60px;
	left: 625px;
font: 230% Times, serif;
        font-weight: bold; }
#IssueTrackerButton {
	margin: 0;
	position: absolute;
	top: 60px;
	left: 805px;
font: 230% Times, serif;
        font-weight: bold; }

#LoginStatus {
        margin-top: .5em; 
	margin-bottom: .5em; 
        color: black;
        font: 130% Times, serif;
        font-weight: bold;}


#Viewers {
	margin: 0;
	position: absolute;
	top: 150px;
	left: 50px; 
        color: black;
        font: 130% Times, serif;
        font-weight: bold;
        color: #C90016
	}

#InventoryCollection {
	margin: 0;
	position: absolute;
	top: 150px;
	left: 350px; 
        height: 250px;
        width: 250px;
        color: black;
        font: 130% Times, serif;
        font-weight: bold;
        color: #C90016
	}


#Administration {
	margin: 0;
	position: absolute;
	top: 425px;
	left: 50px; 
        color: black;
        font: 130% Times, serif;
        font-weight: bold;
        color: #C90016
	}

#Engineering {
	margin: 0;
	position: absolute;
	top: 425px;
	left: 350px; 
        color: black;
        font: 130% Times, serif;
        font-weight: bold;
        color: #C90016
	}

#Development {
	margin: 0;
	position: absolute;
	top: 1000px;
	left: 50px; 
        color: black;
        font: 130% Times, serif;
        font-weight: bold;
        color: #C90016
	}

#outdoorlighting_left {
    float:left;
    width:35%;
    overflow:auto;
}

#outdoorlighting_right{
    float:right;
    width:65%;
    overflow:auto;
}

#outdoorlighting_right ul{
    list-style-type:none;
}"""


